<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><s:text name="context.title"/></title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<meta http-equiv="Cache-Control" content="no-store"/>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Expires" content="0"/>
<link href="${ctx}/css/style.css" type="text/css" rel="stylesheet"/>
<link href="${ctx}/css/Pager.css" rel="stylesheet" type="text/css" />
<link type="text/css" href="${ctx}/css/redmond/jquery-ui-1.8.22.custom.css" rel="stylesheet" />

<script type="text/javascript" src="${ctx}/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="${ctx}/js/jquery-ui-1.8.22.custom.min.js"></script>


<script src="${ctx}/js/table.js" type="text/javascript"></script>

<script src="${ctx}/js/pager.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">

          var pageTotalPages = "1";
          var pageNo = "";
        $(document).ready(function() {
        	var pageTotalPages = $("#pageTotalPages").val();
            var pageNo = $("#pageNo").val();
            $("#pager").pager({ pagenumber: pageNo, pagecount: pageTotalPages, buttonClickCallback: PageClick });
            $(".class-link-set-master").click(function(){
            	setMaster($(this).attr("title"));
            	$('#dialog').dialog('open');
                });


            $('#dialog').dialog({
        		autoOpen: false,
        		width: 300,
        		buttons: {
        			"提交": function() {
        				$.post("group!saveMaster?d="+new Date(),{id:$("#master").val(),subId:$("#teamId").val()},function(data){
        					if(data != ''){
        						alert(data);
        					}else{
            					alert("保存成功！");
        						window.location.reload();
        					}
        					});
        				$(this).dialog("close");
        			},
        			"取消": function() {
        				cleanSelect();
        				$(this).dialog("close");
        			}
        		}
        	});
        });

        PageClick = function(pageclickednumber) {
            $("#pager").pager({ pagenumber: pageclickednumber, pagecount: pageTotalPages, buttonClickCallback: PageClick });
           // $("#result").html("Clicked Page " + pageclickednumber);
            jumpPage(pageclickednumber);
        }

       function setMaster(id){
		$.post("group!master?d="+new Date(),{id:id},function(data){
			if(data != null && data != ''){
				cleanSelect();
				$.each(data,function(inx,o){
					var chkStr = "";
					if(o.isMaster == 1){
						chkStr = " selected=selected ";
					}
					$("#master").append("<option value='"+o.id+"' "+chkStr+">"+o.name+"</option>");
					});
			}
			},"json");
	
        }
		//清空Select
       function cleanSelect(){
			$("#master").empty();
       }

       function setId(id){
			$("#teamId").val(id);
       }
    </script>
</head>
<body>
<br/>
<p align="center"><s:actionmessage theme="mytheme" cssClass="actionMessage"/></p>



<form id="mainForm" action="group.action" method="post">
<input type="hidden" name="page.pageNo" id="pageNo" value="${page.pageNo}"/>
<input type="hidden" name="page.orderBy" id="orderBy" value="${page.orderBy}"/>
<input type="hidden" name="page.order" id="order" value="${page.order}"/>
<input type="hidden" id="pageTotalPages"  value="${page.totalPages}"/>
<tc:timeControler authName="Test时间标签">测试时间控制标签</tc:timeControler>
<h1 class="title01"><img src="${ctx}/images/02_15.gif" width="45" height="42" class="fl"/><a href="group!input">添加团队</a>团队管理 </h1>
<s:if test="page != null && page.result.size() != 0">
<table id="contentTable" class="table_ys tableColor">
	<tr>
		<th nowrap="nowrap" colspan="2">序号</th>
		<th nowrap="nowrap"><a href="javascript:sort('collegeName','asc')">学院</a></th>
		<th nowrap="nowrap"><a href="javascript:sort('groupName','asc')">团队名</a></th>
		<th nowrap="nowrap"><a href="javascript:sort('type','asc')">团队类型</a></th>
		<th nowrap="nowrap">团队人数</th>
		<th nowrap="nowrap">负责人</th>
		<th nowrap="nowrap"><a href="javascript:sort('name','asc')">操作人</a></th>
		<th nowrap="nowrap">操作</th>
	</tr>
	
	<s:iterator value="page.result" status="x" var="v">
	<s:set name="inx">0</s:set>
		<s:if test="#v.subTeam == null">
		<s:set name = "inx"><s:property value="#inx*1 + 1"/></s:set>
		<tr <s:if test="(#x.index+1) % 2 == 0">class="tr1"</s:if><s:else>class="tr2"</s:else>>
			<td nowrap="nowrap" colspan="2"><s:property value="#inx/1"/>&nbsp;</td>
			<td nowrap="nowrap">${v.college.collegeName }&nbsp;</td>
			<td nowrap="nowrap"><s:property value="#v.groupName"/> <a class="ui-state-default ui-corner-al" style="padding:3px 10px;text-decoration:none;" href="group!group?subId=${v.id }">添加小组</a>&nbsp;</td>
			<td nowrap="nowrap"><s:if test="#v.type == 1"><s:property value="@com.suitsoft.ut.commons.Constants@CN_LITI"/></s:if><s:elseif test="#v.type == 2"><s:property value="@com.suitsoft.ut.commons.Constants@CN_KAITI"/></s:elseif><s:elseif test="#v.type == 3"><s:property value="@com.suitsoft.ut.commons.Constants@CN_DABIAN"/></s:elseif><s:else><s:property value="@com.suitsoft.ut.commons.Constants@CN_MIDDLE"/></s:else>&nbsp;</td>
			<td nowrap="nowrap"><s:property value="#v.teacherList.size()"/>&nbsp;</td>
			<td nowrap="nowrap">
				<s:property value="#v.master.teacherName"/>
			&nbsp;</td>
			<td nowrap="nowrap"><s:property value="#v.lastUser.name"/>&nbsp;</td>
			<td nowrap="nowrap"><a class="ui-state-default ui-corner-al" style="padding:3px 10px;text-decoration:none;" href="group!member?id=${v.id }">管理成员</a>、<a class="ui-state-default ui-corner-al class-link-set-master" style="padding:3px 10px;text-decoration:none;" href="javascript:setId('${v.id }')" title="${v.id }">团队负责人</a>、<a class="ui-state-default ui-corner-al" style="padding:3px 10px;text-decoration:none;" href="group!input?id=${v.id}">修改</a>、<a class="ui-state-default ui-corner-al" style="padding:3px 10px;text-decoration:none;" href="group!del?id=${v.id }" onclick="return confirm('确定删除？')">删除</a>&nbsp;</td>
		</tr>
		</s:if>
		<s:if test="#v.teamSet.size() >0">
			<s:iterator value="#v.teamList" status="st" var="v">	
			<tr <s:if test="(#x.index+1) % 2 == 0">class="tr1"</s:if><s:else>class="tr2"</s:else>>
				<td>&nbsp;</td>
				<td>${st.index + 1 }&nbsp;</td>
				<td>&nbsp;</td>
				<td nowrap="nowrap"><s:property value="#v.groupName"/>&nbsp;</td>
				<td nowrap="nowrap"><s:if test="#v.type == 1"><s:property value="@com.suitsoft.ut.commons.Constants@CN_LITI"/></s:if><s:elseif test="#v.type == 2"><s:property value="@com.suitsoft.ut.commons.Constants@CN_KAITI"/></s:elseif><s:elseif test="#v.type == 3"><s:property value="@com.suitsoft.ut.commons.Constants@CN_DABIAN"/></s:elseif><s:else><s:property value="@com.suitsoft.ut.commons.Constants@CN_MIDDLE"/></s:else>&nbsp;</td>
				<td nowrap="nowrap"><s:property value="#v.teacherList.size()"/>&nbsp;</td>
					<td nowrap="nowrap">
				<s:property value="#v.master.teacherName"/>
			&nbsp;</td>
				<td nowrap="nowrap"><s:property value="#v.lastUser.name"/>&nbsp;</td>
				<td nowrap="nowrap"><a class="ui-state-default ui-corner-al" style="padding:3px 10px;text-decoration:none;" href="group!member?id=${v.id }">管理成员</a>、<a class="ui-state-default ui-corner-al class-link-set-master" style="padding:3px 10px;text-decoration:none;" href="javascript:setId('${v.id }')" title="${v.id }">团队负责人</a>、<a class="ui-state-default ui-corner-al" style="padding:3px 10px;text-decoration:none;" href="group!group?subId=${v.subTeam.id }&id=${v.id}">修改</a>、<a class="ui-state-default ui-corner-al" style="padding:3px 10px;text-decoration:none;" href="group!groupDel?id=${v.id }" onclick="return confirm('确定删除？')">删除</a>&nbsp;</td>
			</tr>
			</s:iterator>
		</s:if>
	</s:iterator>
	
</table>
	<div align="center" id="pager" ></div>
</s:if>
</form>

<div id="dialog" title="设置团队负责人">
<input type="hidden" id="teamId" value=""/>
负责人：<select id="master">

</select>
</div>
</body>


</html>